package beans;

import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

/**
 * Message-Driven Bean implementation class for: ExampleMessageDrivenBean
 */
@MessageDriven(
		activationConfig = { @ActivationConfigProperty(
				propertyName = "destinationType", propertyValue = "javax.jms.Queue")
		},
		mappedName ="jms/Firstjmsqueue")
		
public class ExampleMessageDrivenBean implements MessageListener {

    /**
     * Default constructor. 
     */
    public ExampleMessageDrivenBean() {
        // TODO Auto-generated constructor stub
    }
	
	/**
     * @see MessageListener#onMessage(Message)
     */
    public void onMessage(Message message) {
        TextMessage textMessage = (TextMessage) message;
        
        try{
        	System.out.println("am receptionat urmatorul mesaj: ");
        	System.out.println(textMessage.getText());
        	System.out.println();
        }
        catch (JMSException e)
        {
        	e.printStackTrace();
        }
        
    }

}
